package com.cyw.search.controller;

import com.cyw.common.core.controller.BaseController;
import com.cyw.common.core.domain.R;
import com.cyw.search.entity.note.SearchNoteEntity;
import com.cyw.search.mapper.MomentsMapper;
import com.cyw.search.mapper.SearchNoteEntityMapper;
import com.cyw.search.mapper.VideosMapper;
import com.cyw.search.service.SearchEsUserService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashSet;
import java.util.Set;

/**
 * @Author: 二叔
 * @Date: 2022/11/24/18:57
 */
@RestController
@RequestMapping("/addData")
public class AddTestData extends BaseController {

    @Resource
    private MomentsMapper momentsMapper;

    @Resource
    private SearchNoteEntityMapper searchNoteEntityMapper;

    @Resource
    private VideosMapper videosMapper;

    @Resource
    private SearchEsUserService searchEsUserService;

    @GetMapping("addEsData")
    public R addEsData() {
        searchEsUserService.saveOrUpdateUser(1L);
        searchEsUserService.saveOrUpdateUser(2L);
        searchEsUserService.saveOrUpdateUser(3L);
        searchEsUserService.saveOrUpdateUser(4L);
        searchEsUserService.saveOrUpdateUser(1590526563705688066L);
        searchEsUserService.saveOrUpdateUser(1595277993305985025L);

        for (int i = 0; i < 5; i++) {
            SearchNoteEntity searchNoteEntity = new SearchNoteEntity();
            searchNoteEntity.setTitle("活着的意义");
            searchNoteEntity.setContent("在这个世界上,你说活着的意义是什么呢,我们出生在起点的人,无论如何也不能赶得上那些出生在罗马的人吧,那你来说,活着的意义是什么呢");
            searchNoteEntity.setCreator("二叔");
            searchNoteEntity.setCreateTime("2022-11-18");
            searchNoteEntity.setFirstPicture("https://gimg2.baidu.com/image_search/src=http%3A%2F%2Flmg.jj20.com%2Fup%2Fallimg%2F1114%2F041621122252%2F210416122252-1-1200.jpg&refer=http%3A%2F%2Flmg.jj20.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1671880243&t=fe9fccaf204a6d7d12c74a2fc5bad9fe");
            searchNoteEntity.setTypeName("随笔");
            searchNoteEntity.setLocation("39.0,116.0");
            Set<String> set = new HashSet<>();
            set.add("随笔");
            set.add("情感");
            set.add("故事");
            searchNoteEntity.setTags(set);
            searchNoteEntityMapper.insert(searchNoteEntity);
        }


        return R.ok();
    }
}





















